---
<% raise "Expected exactly two instances of db in current deployment" if link('db').instances.length != 2 %>

databases:
  main:
<% link('db').instances.each do |instance| %>
  - id: <%= instance.id %>
    name: <%= instance.name %>
    index: <%= instance.index %>
    address: <%= instance.address %>
<% end %>
  main_properties: <%= link('db').p('foo') %>
  backup:
<% link('backup_db').instances.each do |instance| %>
  - name: <%= instance.name %>
    az: <%= instance.az %>
    index: <%= instance.index %>
    address: <%= instance.address %>
<% end %>
  backup_properties: <%= link('backup_db').p('foo') %>

db_az_link:
  address: <%= link('db').address(azs: ['z1']) %>

optional_backup_link:
<% if_link('backup_db') do |link| %>
  - address: <%= link.address %>
<% end %>
